package com.andy.wan.android.mvp.ui.activity;

import android.widget.FrameLayout;

import com.andy.ui.base.BaseActivity;
import com.andy.ui.tab.BottomTabInfo;
import com.andy.ui.tab.BottomTabLayout;
import com.andy.wan.android.R;
import com.andy.wan.android.mvp.ui.fragment.HomeFragment;
import com.andy.wan.android.mvp.ui.fragment.KnowledgeHierarchyFragment;
import com.andy.wan.android.mvp.ui.fragment.NavigationFragment;
import com.andy.wan.android.mvp.ui.fragment.ProjectViewpagerFragment;
import com.andy.wan.android.mvp.ui.fragment.WxArticleFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;


public class MainActivity extends BaseActivity {

    @BindView(R.id.layout_content)
    FrameLayout mLayoutContent;
    @BindView(R.id.layout_bottom)
    BottomTabLayout mLayoutBottom;

    private List<BottomTabInfo> genBottomTabInfo() {
        List<BottomTabInfo> list = new ArrayList<>();
        //TODO 试试使用注解来实现注入名称和图标
        BottomTabInfo homeTab = new BottomTabInfo();
        homeTab.setFragmentName(HomeFragment.class.getName());
        homeTab.setName("首页");
        homeTab.setIconRes(R.drawable.selector_home_page);

        BottomTabInfo projectTab = new BottomTabInfo();
        projectTab.setFragmentName(ProjectViewpagerFragment.class.getName());
        projectTab.setName("项目");
        projectTab.setIconRes(R.drawable.selector_project_page);

        BottomTabInfo knowledgeTab = new BottomTabInfo();
        knowledgeTab.setFragmentName(KnowledgeHierarchyFragment.class.getName());
        knowledgeTab.setName("体系");
        knowledgeTab.setIconRes(R.drawable.selector_system_page);

        BottomTabInfo navigationTab = new BottomTabInfo();
        navigationTab.setFragmentName(NavigationFragment.class.getName());
        navigationTab.setName("导航");
        navigationTab.setIconRes(R.drawable.selector_navigation_page);

        BottomTabInfo wxArticleTab = new BottomTabInfo();
        wxArticleTab.setFragmentName(WxArticleFragment.class.getName());
        wxArticleTab.setName("公众号");
        wxArticleTab.setIconRes(R.drawable.selector_wx_account_page);

        list.add(homeTab);
        list.add(projectTab);
        list.add(knowledgeTab);
        list.add(navigationTab);
        list.add(wxArticleTab);
        return list;
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    public void initLogic() {
        mLayoutBottom.initTab(genBottomTabInfo(), R.id.layout_content);
    }
}
